package com.yxc.consumer.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * 消费者
 *
 * @author: YXC
 * @time: 2022/12/6 11:12
 **/
@Slf4j
@Component
public class StudentConsumer {

    public static final String TOPIC = "kafka-demo-topic";

    @KafkaListener(topics = {TOPIC}, errorHandler = "myKafkaListenerErrorHandler", groupId = "${spring.kafka.consumer.group.demo-topic-group}")
    public void student(ConsumerRecord<Object, Objects> consumerRecord) {
        //用于测试异常处理
        log.debug("收到消息: {}", consumerRecord.value());
    }

}
